package com.site.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.common.BaseController;
import com.entity.Production;
import com.service.ContactItemsService;
import com.service.ProductCategoryService;
import com.service.ProductionService;

@Controller
@RequestMapping("/")
public class ProinfoController extends BaseController {
	@Autowired
	private ProductCategoryService productCategoryService;
	@Autowired
	private ProductionService productionService;
	@Autowired
	private ContactItemsService contactItemsService;
	@RequestMapping("/proinfo/pro-{id}")
	public String index(HttpServletRequest request, @PathVariable int id){
		this.initCommon(request, productCategoryService, contactItemsService, productionService);
		Production product = this.productionService.findById(id);
		request.setAttribute("product", product);
		List<Production> relateList = this.productionService.findByCategoryInPage(product.getProductCategory().getId(), 0, 4);
		request.setAttribute("relateList", relateList);
		return "site.proinfo";
	}
}
